//
//  OCSSBaseViewController.swift
//  OCSSStoreSwift
//
//  Created by MacMiniKangChe on 2018/10/11.
//  Copyright © 2018年 MacMiniKangChe. All rights reserved.
//

import UIKit

class OCSSBaseViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
        
        navigationController?.navigationBar.barTintColor = UIColor.white;
        navigationController?.navigationBar.shadowImage = UIImage.init();
        navigationController?.navigationBar.tintColor = UIColor.black;
        setBackButton();
    }
    func setBackButton() -> Void {
        let backBtn = UIButton.init(type: UIButtonType.custom);
        backBtn.setImage(UIImage.init(named: "white-back.png"), for: UIControlState.normal);
        let backItem = UIBarButtonItem.init(customView: backBtn);
        navigationItem.backBarButtonItem = backItem;
    }
    func setNavBtn(title: String, isRight: Bool) -> Void {
        let button = UIButton.init(type: UIButtonType.custom);
        if title.hasSuffix(".png"){
            button.setImage(UIImage.init(named: title), for: UIControlState.normal);
        }else{
            button.setTitle(title, for: UIControlState.normal);
            button.titleLabel?.textColor = UIColor.red;
        }
        button.addTarget(self, action: #selector(barButtonEvent(button:)), for: UIControlEvents.touchUpInside);
        let item = UIBarButtonItem.init(customView: button);
        
        if isRight {
            button.tag = 10;
            self.navigationItem.leftBarButtonItem = item;
        }else{
            button.tag = 11;
            self.navigationItem.leftBarButtonItem = item;
        }
        
    }
    @objc func barButtonEvent(button:UIBarButtonItem) -> Void {
        
    }
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }

}
